<template>
  <div class="container">
    <el-dialog
      title="提示"
      :visible.sync="dialogVisible"
      width="30%"
      :beforeClose="close"
    >
      <div>
        <el-radio v-model="checkData.chkState" label="1">通过</el-radio>
        <el-radio v-model="checkData.chkState" label="2">拒绝</el-radio>
        <p>审核意见:</p>
        <el-row>
          <el-input
            type="textarea"
            placeholder="请输入内容"
            :rows="2"
            resize="none"
            v-model="checkData.chkRemarks"
          >
          </el-input>
        </el-row>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="confirm">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { choiceCheck } from '@/api/hmmm/questions'
export default {
  name: 'jxhh',
  props: {
    dialogVisible: {
      type: Boolean,
      required: true,
    },
    data: {
      default: () => {},
      type: Object,
    },
  },
  data() {
    return {
      checkData: {
        id: null,
        chkState: 1,
        chkRemarks: null,
      },
    }
  },
  methods: {
    async confirm() {
      if (this.checkData.chkRemarks.trim().length === 0) {
        return this.$message.warning('请输入审核意见')
      }
      const data = await choiceCheck({
        id: this.data.id,
        chkState: +this.checkData.chkState,
        chkRemarks: this.checkData.chkRemarks,
      })
      this.$emit('close')
      this.checkData.chkRemarks = ''
      this.$message.success('审核成功')
      this.$emit('updateList')
    },
  },
}
</script>

<style >
</style>
